<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\common\logic\admin;

use app\common\model\AppUserModel;

class Appuser
{
	/**
	 * [学校下所有学生的年级]
	 * @return [type] [description]
	 */
	public function grad($shcool_id){
		$data = AppUserModel::where('schoolId',$shcool_id)
							->where('role',1)
							->where('grad','<>','')
							->group('grad')
							->field('grad')
							->select();
		return $data;
	}
	/**
	 * 某一年级下的班级
	 */
	public function classes($shcool_id,$grad){
		$data = AppUserModel::where('schoolId',$shcool_id)
							->where('grad',$grad)
							->where('role',1)
							->where('classes','<>','')
							->field('classes')
							->group('classes')
							->select();
		return $data;
	}

	/**
	 * [某个班级下所有学生]
	 * @param  [type] $shcool_id [description]
	 * @param  [type] $grad      [description]
	 * @param  [type] $classes   [description]
	 * @return [type]            [description]
	 */
	public function user($shcool_id,$grad,$classes){
		$data = AppUserModel::where('schoolId',$shcool_id)->where('grad',$grad)->where('classes',$classes)->field('id,realName')->select();
		return $data;
	}
}